package com.tian.netty.test.login;

import com.tian.netty.message.req.ChargerLoginMsg;
import com.tian.netty.test.TestReqMsgBase;
import com.tian.util.BCDUtil;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-25 10:45
 * {@code @version:} 1.0
 */
public class ChargerLoginDataReq  extends TestReqMsgBase<ChargerLoginMsg> {
    /**
     * 消息体长度
     */
    private static final int LENGTH = 10;

    public ChargerLoginDataReq(short msgType) {
        super(msgType);
    }

    @Override
    public void format() {
        this.msgObject = new byte[LENGTH];
        int index = 0;
        //0---0x68
        this.msgObject[index++] = MSG_HEAD;
        //消息类型
        this.msgObject[index++] = (byte) msgType;

        //8位---2到10  充电桩编号
        byte[] gunNo = BCDUtil.str2Bcd(responseBody.getGunNo());
        //前面部分补充0
        for (int i = 0; i < 8 - gunNo.length; i++) {
            this.msgObject[index++] = FILLED_VAL;
        }
        for (byte b : gunNo) {
            this.msgObject[index++] = b;
        }
    }
}
